/**
 *
 * @param table {Table}
 * @param uninstall {boolean} 是否在生成代码时注释该方法，用于备用
 * @returns {string}
 */
const deleteById = (table, uninstall = false) => {
  const {names: {JavaName}} = table
  return `// <-
  /**
   * 按 encryptId 删除
   * @param encryptId {string} {@link ${JavaName}#encryptId}
   * @return {Promise<Result>}
   */
  static async deleteById(encryptId) {
    return await http
      .delete(deleteByIdURL.format(id || 0))
      .then(Result.ofResponse)
      .catch(Result.ofCatch)
  }
  /**
   * 按 encryptId 批量删除
   * @param encryptIds {string[]} {@link ${JavaName}#encryptId}
   * @return {Promise<Result>}
   */
  static async deleteByIds(encryptIds) {
    return await http
      .delete(deleteByIdsURL, encryptIds)
      .then(Result.ofResponse)
      .catch(Result.ofCatch)
  }
`.split('\n')
    .map(row => (uninstall ? '//' : '') + row)
    .join('\n')
}
export const deleteByIdInstall = table => deleteById(table)
export const deleteByIdUninstall = table => deleteById(table, true)
